package com.xone.xapp;

import org.json.JSONArray;
import org.json.JSONObject;

public class OverheadListUserHolder extends BasicListHolder {
	protected String id;
	protected String overheadType;
	protected String lastUpdated;
	protected String dateCreated;
	protected String imageId;
	protected String titleName;
	protected String overheadTypeName;
	protected String checkStatus;
	protected String checkStatusName;
	protected String refId;
	protected String remark;
	protected String desc;
	public OverheadListUserHolder(JSONObject o) {
		id = JSONUtils.getStringFromJSONObject(o, "id");
		String overheadType = JSONUtils.getStringFromJSONObject(o, "overheadType");
		overheadTypeName = JSONUtils.getStringFromJSONObject(o, "overheadTypeName");
		checkStatus = JSONUtils.getStringFromJSONObject(o, "checkStatus");
		checkStatusName = JSONUtils.getStringFromJSONObject(o, "checkStatusName");
		refId = JSONUtils.getStringFromJSONObject(o, "refId");
		remark = JSONUtils.getStringFromJSONObject(o, "remark");
		JSONObject refObject = null;
		if ("3".equals(overheadType)) {//求购类型的
			refObject = JSONUtils.getJSONObjectForKey(o, "purchase");
			titleName = JSONUtils.getStringFromJSONObject(refObject, "purchaseName");
			desc = JSONUtils.getStringFromJSONObject(refObject, "purchaseDesc");
		} else {
			refObject = JSONUtils.getJSONObjectForKey(o, "product");
			titleName = JSONUtils.getStringFromJSONObject(refObject, "productName");
			desc = JSONUtils.getStringFromJSONObject(refObject, "productDesc");
		}
		JSONArray ids = JSONUtils.getJSONArrayForKey(refObject, "ids");
		if (null != ids && ids.length() > 0) {
			imageId = JSONUtils.getStringFromJSONArray(ids, 0);
		}
		lastUpdated = StringUtils.formatStringDate(JSONUtils.getStringFromJSONObject(o, "lastUpdated"));
		dateCreated = StringUtils.formatStringDate(JSONUtils.getStringFromJSONObject(o, "dateCreated"));
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getOverheadType() {
		return overheadType;
	}
	public void setOverheadType(String overheadType) {
		this.overheadType = overheadType;
	}
	public String getLastUpdated() {
		return lastUpdated;
	}
	public void setLastUpdated(String lastUpdated) {
		this.lastUpdated = lastUpdated;
	}
	public String getImageId() {
		return imageId;
	}
	public void setImageId(String imageId) {
		this.imageId = imageId;
	}
	public String getTitleName() {
		return titleName;
	}
	public void setTitleName(String titleName) {
		this.titleName = titleName;
	}
	public String getOverheadTypeName() {
		return overheadTypeName;
	}
	public void setOverheadTypeName(String overheadTypeName) {
		this.overheadTypeName = overheadTypeName;
	}
	public String getCheckStatus() {
		return checkStatus;
	}
	public void setCheckStatus(String checkStatus) {
		this.checkStatus = checkStatus;
	}
	public String getCheckStatusName() {
		return checkStatusName;
	}
	public void setCheckStatusName(String checkStatusName) {
		this.checkStatusName = checkStatusName;
	}
	public String getRefId() {
		return refId;
	}
	public void setRefId(String refId) {
		this.refId = refId;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	public void setDateCreated(String dateCreated) {
		this.dateCreated = dateCreated;
	}
	@Override
	public String getDateCreated() {
		return dateCreated;
	}
	@Override
	public String getDataCreatedName() {
		return "product.dateCreated";
	}

}
